﻿function ShowModalPopup() {
    $find("mpePopup").show();
    return false;
}
function HideModalPopup() {
    $find("mpePopup").hide();
    return false;
}

function checkExistsUser(val, func, funcerr) {
    var param = new Object();
    param["username"] = val;
    callAjax("../Views/CheckCode.ashx", param, func, funcerr);
}

//chon tat ca tren luoi
function SelectAll(gridId, id) {
    var grid = document.getElementById(gridId);
    var cell;
    if (grid.rows.length > 0) {
        for (i = 1; i < grid.rows.length; i++) {
            cell = grid.rows[i].cells[0];
            for (j = 0; j < cell.childNodes.length; j++) {
                if (cell.childNodes[j].type == "checkbox") {
                    cell.childNodes[j].checked = document.getElementById(id).checked;
                }
            }
        }
    } 
}

//kiem tra ten nguoi dung co ton tai chua
function callAjax(urlhandler, param, func, funcerr) {
    $.ajax({
        url: urlhandler,
        data: param,
        dataType: 'json',
        type: 'GET',
        contentType: 'application/json',
        success: function (data) {
            func(data);
        },
        error: function (data, status, jqXHR) {
            if (funcerr != null)
                funcerr();
        }
    });
}
